<?php
namespace Admin\Controller;
use Think\Controller;

class AdminaddController extends CommonController {
    public function index(){

        $roles = M('auth_group')->field('id,title')->select();

        $this->assign('roles',$roles);
        
        $this->display();
    }

    public function addadmin(){
    	$data = I('post.');
    	$check = D('auth_group_access');
    	if(!$check->create($data,1)){

    		$this->ajaxreturn(['error'=>1,'info'=>$check->getError()]);
    	}
		$data['create_time'] = time();
		$data['password'] = md5($data['pass']);

        //var_dump($data);exit;
		if(M('auth_group_access')->add($data)){
			$this->ajaxReturn(['error'=>0,'info'=>'注册成功']);
		}else{
			$this->ajaxReturn(['error'=>1,'info'=>'注册失败']);
		}
		

    }
}

?>